﻿using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Enums;
using SelfMadeMillionaire.Web.Infrastructure.Attributes;
using SelfMadeMillionaire.Web.Infrastructure.ViewModels.PayPal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.Web.Infrastructure.ViewModels.Account
{
	public class SubscriptionInfoViewModel
	{
        public int ID { get; set; }
		private SubscriptionType? _subscriptionLevel;
		private bool _isSmmSubscribe;

		[RequiredIf("IsSMM", true, ErrorMessage = "Please select subscription level")]
		public SubscriptionType? SubscriptionLevel
		{
			get { return _subscriptionLevel; }
			set
			{

				_subscriptionLevel = value;

				if (!IsSMMSubscribe)
				{
					SMMSubscriptionName = "No Subscription";
					return;
				
				}
				switch (_subscriptionLevel)
				{
					case SubscriptionType.Free:
						SMMSubscriptionName = "Free Subscription";
						break;
					case SubscriptionType.Silver:
						SMMSubscriptionName = "Silver Subscription";
						break;
					case SubscriptionType.Gold:
						SMMSubscriptionName = "Gold Subscription";
						break;
                    case SubscriptionType.Platinum:
                        SMMSubscriptionName = "Platinum Subscription";
                        break;
					case null:
						break;
					default:
						throw new ArgumentOutOfRangeException();
				}
			}
		}



		public string SMMSubscriptionName { get; set; }

		public bool IsSMM { get; set; }
		public bool IsMMM { get; set; }

		public double Balance { get; set; }

		public DateTime ExperationDate { get; set; }

		public string sExpirationDate
		{
			get
			{
				if (IsSMMSubscribe)
				{
					if (SubscriptionLevel == SubscriptionType.Free)
						return "N/A";

					return ExperationDate.ToShortDateString();
				}

				return "N/A";
				
			}
		}


		public string Status { get; set; }
		


		
		

		public Product[] ProductList { get; set; }

		public bool IsSMMSubscribe
		{
			get { return _isSmmSubscribe; }
			set
			{
				_isSmmSubscribe = value;

				if (_isSmmSubscribe)
				{
					Status = "Active";
				}
				else
				{
					Status = "Inactive";
				}

			}
		}

		public bool IsMMMSubscribe { get; set; }
	}
}
